Skip to content

fix: resilient default-company resolution on dashboard open#6

Merged
NagariaHussain merged 1 commit into
developfrom
fix/default-company-resolution
Jun 4, 2026
Merged

fix: resilient default-company resolution on dashboard open#6
NagariaHussain merged 1 commit into
developfrom
fix/default-company-resolution

Conversation

@NagariaHussain
Copy link
Copy Markdown
Contributor

Closes #4

Problem

Opening Ledger Lab showed a warning popup and no data whenever the resolved default company didn't exist. On this bench a stale user default (Company = "LL E2E Probe", a leftover from an E2E run pointing at a company that no longer exists) took precedence over the valid Global Default BWH, so get_balances threw Company LL E2E Probe does not exist. and the dashboard rendered blank.

Fix

  • Backend (_resolve_company): a missing or stale default no longer throws. It falls back to the first company the user can read, so the page always opens with data. The Company picker only ever submits real companies, so this lenient fallback never masks a genuine bad selection. Only a truly company-less site still errors (with a clearer message).
  • Frontend (sync_company_field): the picker is synced to the server-resolved company after refresh(), so a stale client-side default is corrected to the company actually being shown. Guarded so it doesn't retrigger a reload.

Verification (agent-browser, ledger.localhost)

  • Page loads with picker showing BWH (not the stale LL E2E Probe).
  • All boxes populated, equation reads ✓ Balanced, recent-transactions feed has rows.
  • No warning popup.
  • _resolve_company(None), _resolve_company("LL E2E Probe"), and _resolve_company("BWH") all return BWH.

🤖 Generated with Claude Code

Ledger Lab opened to a warning + no data when the resolved default
company didn't exist — e.g. a stale user default (a leftover "LL E2E
Probe" pointing at a deleted company) took precedence over the valid
Global Default and made get_balances throw "Company X does not exist."

Key decisions:
- Backend `_resolve_company` no longer throws on a missing/stale default;
  it falls back to the first company the user can read (the Company
  picker only ever submits real companies, so this never masks a genuine
  bad selection). Only a company-less site still errors.
- Frontend syncs the picker to the server-resolved company via
  `sync_company_field()`, so a stale client-side default is corrected to
  the company actually being shown (guarded against a reload loop).

Files: ledger_lab/api/dashboard.py, ledger_lab/.../page/ledger_lab/ledger_lab.js

Verified (agent-browser, ledger.localhost): page loads with picker=BWH,
all boxes populated, equation "✓ Balanced", feed rows present, no warning.

Notes for next iteration: issues #5 (transaction filters) and #3
(equation card UI) remain open.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@NagariaHussain NagariaHussain merged commit afe0c3e into develop Jun 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default company must be selected when ledger lab page is opened

1 participant